﻿
// ..\EntityModel.xlsx

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data; 

namespace EntityMetadata 
{
	public partial class EntityModel
	{
		private const string DataTypeTable = "DataType";
		private const string EntityTable = "Entity";
		private const string PropertyTable = "Property";
        
        private string[] _tables = { DataTypeTable, EntityTable, PropertyTable,  };
	}


    public partial class DataTypeDef: DefBase 
    {
        public string TypeName { get; set; }
        public string BaseType { get; set; }
        public int? Size { get; set; }
        public int? Scale { get; set; }
        public string CLRType { get; set; }

        public static DataTypeDef CreateInstance(DataRow r)
        {
            DataTypeDef i = new DataTypeDef();
            i.TypeName = Getstring(r, "TypeName");
            i.BaseType = Getstring(r, "BaseType");
            i.Size = Getnullableint(r, "Size");
            i.Scale = Getnullableint(r, "Scale");
            i.CLRType = Getstring(r, "CLRType");
            return i;
        }
    }

    public partial class EntityDef: DefBase 
    {
        public string EntityName { get; set; }
        public string TableName { get; set; }
        public string EntitySource { get; set; }
        public string EntityType { get; set; }

        public static EntityDef CreateInstance(DataRow r)
        {
            EntityDef i = new EntityDef();
            i.EntityName = Getstring(r, "EntityName");
            i.TableName = Getstring(r, "TableName");
            i.EntitySource = Getstring(r, "EntitySource");
            i.EntityType = Getstring(r, "EntityType");
            return i;
        }
    }

    public partial class PropertyDef: DefBase 
    {
        public string EntityName { get; set; }
        public string PropertyName { get; set; }
        public string DataTypeName { get; set; }
        public bool Persistent { get; set; }
        public bool Exposed { get; set; }
        public string References { get; set; }
        public bool? IncludeChild { get; set; }
        public bool? IncludeAtParent { get; set; }
        public bool PrimaryKey { get; set; }
        public bool Required { get; set; }
        public bool Unique { get; set; }
        public double? RangeFrom { get; set; }
        public double? RangeTo { get; set; }
        public string RegularExpression { get; set; }
        public string Description { get; set; }

        public static PropertyDef CreateInstance(DataRow r)
        {
            PropertyDef i = new PropertyDef();
            i.EntityName = Getstring(r, "EntityName");
            i.PropertyName = Getstring(r, "PropertyName");
            i.DataTypeName = Getstring(r, "DataTypeName");
            i.Persistent = Getbool(r, "Persistent");
            i.Exposed = Getbool(r, "Exposed");
            i.References = Getstring(r, "References");
            i.IncludeChild = Getnullablebool(r, "IncludeChild");
            i.IncludeAtParent = Getnullablebool(r, "IncludeAtParent");
            i.PrimaryKey = Getbool(r, "PrimaryKey");
            i.Required = Getbool(r, "Required");
            i.Unique = Getbool(r, "Unique");
            i.RangeFrom = Getnullabledouble(r, "RangeFrom");
            i.RangeTo = Getnullabledouble(r, "RangeTo");
            i.RegularExpression = Getstring(r, "RegularExpression");
            i.Description = Getstring(r, "Description");
            return i;
        }
    }
}

